define(function(require){
	var main = require('/static/main.js');
	require('/static/jquery.z-pager.js');
	var m = new main();
	function Cont(){
		this.Fun._init();
	}
	Cont.prototype.Fun = {
		_init:function(){
		    this.getlist();
			this.bindEvent();
		},
		getlist:function(){
			
        	$("#pager").zPager({
		        url:'/news/modules',
		        pageData:4,
		        btnShow: false,
		        pageStep:8,
		        dataRender: function(data){
		        		var str = '';
		        		if(data[0] == "暂无数据"){
		        			$('#pager').hide();
		        		}else{
		        			$('#pager').show();
			        		$.each(data,function(k,v){
			               		str+='<div class="m-b-20 ">\
					                        <div class="newsmodel_choseall">\
					                            <div class="row" style="margin:0px;">\
					                                <div class="col-md-12" style="padding-left: 0px;">\
					                                    <div class="tit">模板：'+v.Title+'</div>\
					                                    <div>短信内容 ：'+v.Content+'</div>\
					                                </div>\
					                            </div>\
					                        </div>\
					                    </div>'
			               	})
		               		$('.contant').html(str);
		        		}
		        },
		    });
		},
		bindEvent:function(){
			var _this = this;
			$('.btn-info').click(function(){
				var tit = $('.form-controlinput input').val().replace(/\s/g, "");
				var con = $('.form-controltextarea textarea').val().replace(/\s/g, "");
				if(tit == ''){
					layer.msg('标题不能为空');
					return false
				}
				if(tit.length > 10){
					layer.msg('标题不能多余10个字');
					return false
				}
				if(con == ''){
					layer.msg('内容不能为空');
					return false
				}
				if(con.length > 140){
					layer.msg('内容不能多余140个字');
					return false
				}
				$.ajax({
	                type: "POST",
	                url: "/news/create-modle",
	                dataType: "json",
	                data:{Title:tit,Content:con},
	                success: function (ret) {
	            	   var str = '';
	            	   if(ret.IsBizSuccess){
	        	   			layer.msg('创建成功');
	        	   			_this.getlist();
	            	   }else{
	            	   	   layer.msg(ret.ErrMsg);
						   return false
	            	   }
	                }
	            });
			})
		}


	}
	var a = new Cont();

})